﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace Scrabble.ViewModels
{
    public class SelectableCollection<T> : ObservableCollection<T> where T : class, ISelectable
    {
        public IEnumerable<T> SelectedItems
        {
            get { return this.Where(x => x.IsSelected); }
        }

        public void SelectAll()
        {
            foreach (var item in this.Except(SelectedItems))
                item.IsSelected = true;
        }

        public void UnselectAll()
        {
            foreach (var item in SelectedItems)
                item.IsSelected = false;
        }
    }
}